#ifndef _H_PRINTBUF
#define _H_PRINTBUF

// Add till buf is filled up. Little Crude. Look into
// using strstream. Singleton. Obviously thread-unsafe.
// Assumes main program initializes it. And only initialized once.
//
class PrintBuf
{
  char     buf[128];
  uint16_t index;
  boolean  overflow;

  static  PrintBuf* loneSingleton;

private:
  void printSerial();

public:
  PrintBuf();
  static PrintBuf* singleton() {return loneSingleton;}

  boolean init();

  void clear();
  void add(uint8_t,char sep='\n');
  void add(uint16_t,char sep='\n');
  void add(const char*, char sep='\n');

  // does an implicit clear(), ie. deletes data after printing

  boolean print();

 public:
  enum {EQUAL='=',SPACE=' '} separators;

};

#endif
